package cn.enilu.flash.conf;

import cn.enilu.flash.conf.properties.LocalFileProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/10/26 7:38)
 * @Version v1.0
 * @Modify
 **/
@Configuration
public class LocalFileConfig {

    @Value("${file.local.url}")
    private String url;
    @Value("${file.local.dir}")
    private String dir;
    @Value("${file.local.imgMax}")
    private String imgMax;
    @Value("${file.local.pdfMax}")
    private String pdfMax;

    @Bean
    public LocalFileProperties initProperties(){
        return new LocalFileProperties(url, dir, imgMax, pdfMax);
    }

    /**
     * @Description 重新加载配置信息
     * @Author  Spark
     * @Date    Created in (2019/11/06 9:02)
     * @param	url
     * @param	dir
     * @param	imgMax
     * @param	pdfMax
     * @Return  void
     **/
//    public static void reload(String url, String dir, String imgMax, String pdfMax){
//        DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory)SpringContextHolder.getApplicationContext().getAutowireCapableBeanFactory();
//        BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(LocalFileProperties.class);
//        beanDefinitionBuilder.addPropertyValue("url", url);
//        beanDefinitionBuilder.addPropertyValue("dir", dir);
//        beanDefinitionBuilder.addPropertyValue("imgMax", imgMax);
//        beanDefinitionBuilder.addPropertyValue("pdfMax", pdfMax);
//
//        defaultListableBeanFactory.registerBeanDefinition("localFileProperties", beanDefinitionBuilder.getBeanDefinition());
//    }


}
